const axios = require('axios');
const fs = require('fs-extra') // 文件读写
const path = require('path')

// 添加请求拦截器
axios.interceptors.request.use(function (config) {
    // 在发送请求之前做些什么
    console.log(config, 'config');
    return config;
}, function (error) {
    // 对请求错误做些什么
    return Promise.reject(error);
});

// 单次
const getUrl1 = () => {
    let limit = 1000
    let url = ``
    axios.get(url)
        .then((response) => {
            let info = (response.data || {}).rows || []
            // 文件导出
            const file = `\\records\\${Date.now()}.txt`;
            const filePath = path.resolve('./') + file;
            fs.writeFileSync(filePath, JSON.stringify(info, null, 2));
        })
        .catch((error) => {
            console.error(error);
        });
}

getUrl1()